//
//  GlobalDefine.swift
//  sxwb
//
//  Created by TianDu on 2016/11/14.
//  Copyright © 2016年 TianDu. All rights reserved.
//

import UIKit
import Foundation

let Space:CGFloat = 10.0

let KScreenWidth  :CGFloat  = UIScreen.main.bounds.size.width
let KScreenHeight :CGFloat  = UIScreen.main.bounds.size.height

let ThemeColor = UIColor.orange
let WhiteColor = UIColor.white
let BlackColor = UIColor.black
let GrayColor = UIColor.gray
let BorderColor = UIColor(red: 238.0/255.0, green: 238.0/255.0, blue: 238.0/255.0, alpha: 1.0)

let AccessToken = "access_token"
let ExpiresIn = "expires_in"
let Uid = "uid"



let AppKay = "984034060"
let AppSecret = "15e176d074decb05f86201cc0c09f5b0"
let RedirectUri = "http://www.163.com" // 回调地址
let OAuthUrl = "https://api.weibo.com/oauth2/authorize"  // oauth认证地址
let TokenUrl = "https://api.weibo.com/oauth2/access_token" //获取AccessToken地址


func view_X (_ view:UIView) -> CGFloat{
    
    return view.frame.origin.x
}

func view_Y (_ view:UIView) -> CGFloat{
    
    return view.frame.origin.y
}

func view_W (_ view:UIView) -> CGFloat{
    
    return view.frame.size.width
}

func view_H (_ view:UIView) -> CGFloat{
    
    return view.frame.size.height
}

func view_MaxX (_ view:UIView) -> CGFloat{
    
    return view.frame.maxX
}

func view_MaxY (_ view:UIView) -> CGFloat{
    
    return view.frame.maxY
}

func xPrint <T>(_ message:T ,file:String = #file,funcName:String = #function ,line:Int = #line){
    
    #if DEBUG
        let fileName = (file as NSString).lastPathComponent
        
        print("\(fileName):[\(funcName)]:\(line)-\(message)")
    #endif
}

func createLabel(_ frame: CGRect ,title : String, titleColor :UIColor ,font: CGFloat,alignment :NSTextAlignment) -> UILabel {
    
    let label = UILabel(frame: frame)
    label.text = title
    label.font = UIFont.systemFont(ofSize: font)
    label.textColor = titleColor
    label.textAlignment = alignment
    
    
    return label
}

func formDateString(_ time:NSNumber) -> String {
    
    let date = Date(timeIntervalSince1970: TimeInterval(time))
    
    let formatter = DateFormatter()
    formatter.dateFormat = "MM-dd HH:mm"
    let dateStr = formatter.string(from: date)
    
    return dateStr
}

func getTxetHeight(_ text:String) -> CGFloat {
    
    let attributes = [NSFontAttributeName: UIFont.systemFont(ofSize: 14)]
    let option = NSStringDrawingOptions.usesLineFragmentOrigin
    let rect:CGRect = text.boundingRect(with: CGSize(width:KScreenWidth-Space*3-30,height:CGFloat(MAXFLOAT)), options: option, attributes: attributes, context: nil)
    let height = ceilf(Float(rect.size.height))
    
    return CGFloat(height);
    
}



